// pages/sharewebview/sharewebview.js
//获取应用实例
var app = getApp()
let httpUrl = app.globalData.httpUrl;
let thisErpId = app.globalData.thisErpId;
Page({
  data: {
    friendData: '',
    promptBlock: true,
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (e) {
    let friendId = e.friendId;
    // friendId = 12;
    this.getFriend(friendId);
  },
  getFriend: function (id) {
    if (wx.showLoading) {
      wx.showLoading({
        title: '正在加载...',
      })
    }
    wx.request({
      url: httpUrl + 'slsw/showfriends.do',
      method: 'POST',
      data: `weChatKey=9237B361957490BA9644A710A5E3DD84&&Data={friendId:${id},is_refresh:'true',page_num:1,item_num:10,erpId:'${thisErpId}'}`,
      header: {
        'content-type': 'application/x-www-form-urlencoded;charset=UTF-8"'
      },
      success: (res) => {
        let list = res.data.Data[0];
        console.log(list)
        list.create_time = (list.create_time).substr(0,16);
        this.setData({
          friendData: list
        })
        wx.hideLoading();
      },
      fail: () => {
        wx.hideLoading();
        wx.showToast({
          title: '服务器开了个小差，请稍后再试!',
          icon: 'loading'
        })
      }
    })
  },
  hidePrompt: function(){
    this.setData({
      promptBlock: false
    })
  },
  // 首页图片预览
  preimage: function (e) {
    let current = e.target.dataset.src;
    let index = e.target.dataset.index;
    let photos = this.data.friendData.photos;
    // current = httpUrl + '/slsw/img/qr-code.png'
    wx.previewImage({
      current: current, // 当前显示图片的http链接  
      urls: photos // 需要预览的图片http链接列表  
    })
  },
  onePreimage:function(e){
    let current = httpUrl + '/slsw/img/qr-code.png'
    let photos = [];
    photos.push(current)
    wx.previewImage({
      current: current, // 当前显示图片的http链接  
      urls: photos // 需要预览的图片http链接列表  
    })
  },
  downClose: function (e) {
    this.setData({
      downBlock: false,
    })
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})